#! /usr/bin/env python
# -*- coding: utf-8 -*-

# Copyright (c) JoinQuant Development Team
# Author: Huayong Kuang <kuanghuayong@joinquant.com>

import zmq

context = zmq.Context()
# context.setsockopt(zmq.SNDTIMEO, 5)
# context.setsockopt(zmq.SNDTIMEO, 5)
# context.setsockopt(zmq.LINGER, 5)
# print("socket SNDTIMEO option:", context.getsockopt(zmq.SNDTIMEO))

print("Connecting to server...")
socket = context.socket(zmq.REQ)
# socket.setsockopt_string(zmq.SOCKS_PROXY, "127.0.0.1:8080")
# socket.connect("tcp://127.0.0.1:5555")
socket.connect("tcp://offline2:5555")

for request in range(10):
    print("Sending request %s ..." % request)
    socket.send(b"Hello")

    print("Wait reply ...")
    message = socket.recv()
    print("Received reply %s [ %s ]" % (request, message))
